// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package elastic

import (
	"gitee.com/go-wares/log/base"
)

type (
	// Entity
	// is a component that define elasticsearch index fields. Mapping
	// like follow.
	//
	//   {
	//       "properties": {
	//           "fields": {"type": "object"},
	//           "level": {"type": "keyword"},
	//           "message": {"type": "text"},
	//           "parent_span_id": {"type": "keyword"},
	//           "parent_span_position": {"type": "integer"},
	//           "pid": {"type": "integer"},
	//           "service_addr": {"type": "keyword"},
	//           "service_name": {"type": "keyword"},
	//           "service_version": {"type": "keyword"},
	//           "span_id": {"type": "keyword"},
	//           "span_position": {"type": "integer"},
	//           "stack": {"type": "text"},
	//           "time": {"type": "date"},
	//           "time_micro": {"type": "long"},
	//           "trace_id": {"type": "keyword"}
	//       }
	//   }
	Entity struct {
		Level     base.Level `json:"level" mock:"INFO"`
		Message   string     `json:"message" mock:"request begin"`
		Stack     string     `json:"stack,omitempty" mock:""`
		Time      string     `json:"time" mock:"2024-04-10T10:36:48.153653+08:00"`
		TimeMicro int64      `json:"time_micro" mock:"1712716608153653"`

		Fields map[string]any `json:"fields,omitempty" mock:""`

		Pid            int    `json:"pid" mock:"3721"`
		ServiceAddr    string `json:"service_addr,omitempty" mock:"192.168.10.123"`
		ServiceName    string `json:"service_name,omitempty" mock:"ii-sketch"`
		ServiceVersion string `json:"service_version,omitempty" mock:"1.0"`

		TraceId            string `json:"trace_id,omitempty" mock:"644683b5fb7aa7eda22596614db63c2b"`
		SpanId             string `json:"span_id,omitempty" mock:"7391bda9673b762c"`
		SpanPosition       int32  `json:"span_position" mock:"1"`
		ParentSpanId       string `json:"parent_span_id,omitempty" mock:"5991bda9673b7632"`
		ParentSpanPosition int32  `json:"parent_span_position" mock:"1"`
	}
)
